﻿Public Class frmPersonas

    Private Sub frmPersonas_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Me.PersonasTableAdapter.Fill(Me.CaserDataSet.personas)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.PersonasTableAdapter.Fill(Me.CaserDataSet.personas)
        cmbParentesco.SelectedIndex = 0

    End Sub

    Private Sub btnSeleccionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeleccionar.Click
        If dgPersonas.SelectedRows IsNot Nothing Then
            Me.Tag = CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).Id & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).nombre & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).apellido & ";" & CType(dgPersonas.CurrentRow.DataBoundItem.row, caserDataSet.personasRow).dni & ";" & cmbParentesco.SelectedItem
            Me.Close()
        Else
            Me.Tag = Nothing
        End If

    End Sub

    Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Me.Tag = Nothing
        Me.Close()
    End Sub
    Public Sub parentesco(ByVal visible As Boolean)

        lblParentesco.Visible = visible
        cmbParentesco.Visible = visible

    End Sub



    Private Sub txtFiltro_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFiltro.TextChanged
        PersonasBindingSource.Filter = "dni Like '" & txtFiltro.Text & "%'"
    End Sub

    Private Sub txtFiltroNombre_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFiltroNombre.TextChanged
        PersonasBindingSource.Filter = "nombre Like '" & txtFiltroNombre.Text & "%' or apellido Like '" & txtFiltroNombre.Text & "%'"
    End Sub

    Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click
        Dim frmCliente As NuevoCliente
        frmCliente = New NuevoCliente
        frmCliente.nuevoCliente(False)
        frmCliente.ShowDialog()
    End Sub

    Private Sub cmbParentesco_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbParentesco.SelectedIndexChanged

    End Sub


End Class